<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Annotations</title>
</head>

<body>

<h2>Step Annotations</h2>

<p>JBehave supports the following method step annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Given.html">@Given</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/When.html">@When</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Then.html">@Then</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Alias.html">@Alias</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Aliases.html">@Aliases</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Pending.html">@Pending</a>
    </li>
</ul>
<p>Each annotation holds a regex pattern as value, which is used to
match the <a href="candidate-steps.html">candidate steps</a> to the
textual step:</p>

<pre class="brush: java">
    @Given("a stock of symbol $symbol and a threshold of $threshold")
    public void aStock(String symbol, double threshold) {
        // ...
    }

    @When("the stock is traded at $price")
    @Alias("the stock is exchanged at $price") // single alias    
    public void theStockIsTradedAt(double price) {
        // ...
    }

    @Then("the alert status should be $status")
    @Aliases(values={"the trader should be alerted of status $status",
                     "the alert status is at $status"}) // multiple aliases    
    public void theAlertStatusShouldBe(String status) {
        // ...
    }
</pre>

<p>The use of <a href="aliases.html">aliases</a> is optional.</p>

<h2>Scenario Annotations</h2>

<p>JBehave supports the following method scenario annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/BeforeScenario.html">@BeforeScenario</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/AfterScenario.html">@AfterScenario</a>
    </li>
</ul>
<p>The <b>@BeforeScenario</b> and <b>@AfterScenario</b> annotations allow
the corresponding methods to be executed before and after each scenario.  Optionally, the <a
    href="javadoc/core/org/jbehave/core/annotations/ScenarioType.html">ScenarioType</a> can be specified 
    to execute only upon that type, e.g. for <a href="parametrised-scenarios.html">scenarios parametrised by examples</a>.
In addition, <b>@AfterScenario</b> allows the setting of an optional <a
    href="javadoc/core/org/jbehave/core/annotations/AfterScenario.Outcome.html">Outcome</a>
value, which specifies whether the method should be executed depending
on the outcome of the scenario:</p>

<pre class="brush: java">

    @BeforeScenario
    public void beforeEachScenario() {
        // ...
    }

    @BeforeScenario(uponType=ScenarioType.EXAMPLE)
    public void beforeEachExampleScenario() {
        // ...
    }
        
    @AfterScenario // equivalent to  @AfterScenario(uponOutcome=AfterScenario.Outcome.ANY)
    public void afterAnyScenario() {
        // ...
    }

    @AfterScenario(uponType=ScenarioType.EXAMPLE)
    public void afterEachExampleScenario() {
        // ...
    }
        
    @AfterScenario(uponOutcome=AfterScenario.Outcome.SUCCESS)
    public void afterSuccessfulScenario() {
        // ...
    }
        
    @AfterScenario(uponOutcome=AfterScenario.Outcome.FAILURE)
    public void afterFailedScenario() {
        // ...
    }
</pre>

<h2>Story Annotations</h2>

<p>JBehave supports the following method story annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/BeforeStory.html">@BeforeStory</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/AfterStory.html">@AfterStory</a>
    </li>
</ul>
<p>The <b>@BeforeStory</b> and <b>@AfterStory</b> annotations allow
the corresponding methods to be executed before and after each story, either a GivenStory or not:</p>

<pre class="brush: java">

    @BeforeStory // equivalent to @BeforeStory(uponGivenStory=false)
    public void beforeStory() {
        // ...
    }

    @BeforeStory(uponGivenStory=true)
    public void beforeGivenStory() {
        // ...
    }
        
    @AfterStory // equivalent to @AfterStory(uponGivenStory=false)
    public void afterStory() {
        // ...
    }

    @AfterStory(uponGivenStory=true)
    public void afterGivenStory() {
        // ...
    }
    
</pre>

<h2>Stories Annotations</h2>

<p>JBehave supports the following method stories annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/BeforeStories.html">@BeforeStories</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/AfterStories.html">@AfterStories</a>
    </li>
</ul>
<p>The <b>@BeforeStories</b> and <b>@AfterStories</b> annotations allow
the corresponding methods to be executed before and after a collection of stories:</p>

<pre class="brush: java">

    @BeforeStories
    public void beforeStories() {
        // ...
    }

    @AfterStories
    public void afterStories() {
        // ...
    }
    
</pre>

<h2>Parameter Annotations</h2>

<p>JBehave supports the following parameter annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Named.html">@Named</a>
    </li>
</ul>
<p>Parameter annotations are used in <a
    href="parameter-injection.html">parameter injection</a>.</p>

<h2>Configuration Annotations</h2>

<p>JBehave supports the following configuration annotations:</p>

<ul>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/AsParameterConverter.html">@AsParameterConverter</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/Configure.html">@Configure</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/UsingEmbedder.html">@UsingEmbedder</a>
    </li>
    <li><a
        href="javadoc/core/org/jbehave/core/annotations/UsingSteps.html">@UsingSteps</a>
    </li>
    <li><a
        href="javadoc/guice/org/jbehave/core/annotations/guice/UsingGuice.html">@UsingGuice</a>
    </li>
    <li><a
        href="javadoc/needle/org/jbehave/core/annotations/needle/UsingNeedle.html">@UsingNeedle</a>
    </li>
    <li><a
        href="javadoc/needle/org/jbehave/core/annotations/needle/NeedleInjectionProvider.html">@NeedleInjectionProvider</a>
    </li>
    <li><a
        href="javadoc/pico/org/jbehave/core/annotations/pico/UsingPico.html">@UsingPico</a>
    </li>
    <li><a
        href="javadoc/spring/org/jbehave/core/annotations/spring/UsingSpring.html">@UsingSpring</a>
    </li>
</ul>

<div class="clear">
<hr />
</div>

</body>
</html>
